package engine

import (
    "github.com/ungerik/go3d/vec3"
)

type World struct {
    blocks[] Block
    Width, Length, Height uint
    Light,
    Camera vec3.T
}

func (world *World) Init(width, length, height uint) {
    world.Width = width
    world.Length = length
    world.Height = height
    world.blocks = make([]Block, world.Width * world.Width * world.Height + world.Height * world.Width + world.Width)
}

func (world World) GetBlock(x, y, z uint) Block {
    if(x >= world.Width || y >= world.Length || z >= world.Height) {
        return(Block{})
    }
    index := z * world.Length * world.Height + y * world.Width + x
    return world.blocks[index]
}

func (world World) SetBlock(x, y, z uint, block Block) {
    if(x >= world.Width || y >= world.Length || z >= world.Height) {
        return
    }
    index := z * world.Length * world.Height + y * world.Width + x
    world.blocks[index] = block
}
